﻿using PnFramework;
using System.Collections.Generic;

namespace UnitySmallTheater
{
    /// <summary>
    /// 角色数据
    /// </summary>
    public class RoleData
    {
        public float Hp;
        public float MoveSpeed;
        public float ViewDistance;
        public float Aggressivity;
        public float AttackDistance;
        public float AttackSpeed;

        public RoleData(float hp, float viewDistance, float moveSpeed, float aggressivity, float attackDistance, float attackSpeed)
        {
            Hp = hp;
            ViewDistance = viewDistance;
            MoveSpeed = moveSpeed;
            Aggressivity = aggressivity;
            AttackDistance = attackDistance;
            AttackSpeed = attackSpeed;
        }
    }
    /// <summary>
    /// 游戏数据管理器
    /// </summary>
    public class GameDataMgr : Singleton<GameDataMgr>
    {
        /// <summary>
        /// 基础经验值
        /// </summary>
        private readonly int Experience = 10;
        private readonly Dictionary<string, RoleData> mRoles = new Dictionary<string, RoleData>()
        {
            {"剑士",new RoleData(10,6,3,5,2,3)},
            {"炮手",new RoleData(15,10,1,10,6,1)},
            {"骑兵",new RoleData(8,8,5,7,2,2)},
        };
        /// <summary>
        /// 对比数据
        /// </summary>
        public bool GetData(string profession, out RoleData data)
        {
            return mRoles.TryGetValue(profession, out data);
        }
        /// <summary>
        /// 是否升级
        /// </summary>
        public bool IsUpgrade(int rank, ref int curExperience)
        {
            int experience = rank * curExperience;
            //如果当前经验值 还没有到 当前等级所需要的经验值 
            if (curExperience < experience) return false;
            curExperience = curExperience - experience;
            return true;
        }
    }
}
